package com.raycloud.erp.omll.provider.model.vo;

import com.omall.open.sdk.domain.OrderListInfo;
import com.omall.open.sdk.domain.RefundInfo;
import org.apache.commons.collections.CollectionUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 枫伦
 * @description: TODO
 * @date 2020/10/26 10:49 上午
 */
public class TradeCopierVo extends OrderListInfo implements Serializable {

    private static final long serialVersionUID = 5093405241030433550L;
    /**
     * 通过订单详细接口赋值
     */
    private List<OrderCopierVo> orderDetails;
    /*通过售后单查询接口赋值*/
    private List<RefundInfo> refundInfos;
    /*通过supplySkuCode(商品条码区分售后订单*/
    private Map<String, List<RefundInfo>> refundInfoListMap;

    public List<OrderCopierVo> getOrderDetails() {
        return this.orderDetails;
    }

    public void setOrderDetails(List<OrderCopierVo> orderDetails) {
        this.orderDetails = orderDetails;
    }

    public List<RefundInfo> getRefundInfos() {
        return this.refundInfos;
    }

    public void setRefundInfos(List<RefundInfo> refundInfos) {
        this.refundInfos = refundInfos;
        initRefundInfoMap(refundInfos);
    }

    public Map<String, List<RefundInfo>> getRefundInfoListMap() {
        return refundInfoListMap;
    }

    private void initRefundInfoMap(List<RefundInfo> refundInfos) {
        refundInfoListMap = new HashMap<>();
        if (CollectionUtils.isNotEmpty(refundInfos)) {
            for (RefundInfo refundInfo : refundInfos) {
                List<RefundInfo> list = refundInfoListMap.get(refundInfo.getSupplySkuCode());
                if (list == null) {
                    list = new ArrayList<>();
                }
                list.add(refundInfo);
                refundInfoListMap.put(refundInfo.getSupplySkuCode(), list);
            }
        }
    }


}
